點(diǎn)擊enter按鈕會(huì)關(guān)閉對(duì)話框,留在當(dāng)前Activity,點(diǎn)擊exit按鈕則退出應(yīng)用。
首先是main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF"
android:orientation="vertical" >
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
主Activity代碼CustomAlertDialogActivity.java:
package nbe.sense7.vinci.custom.alertdialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageButton;
public class CustomAlertDialogActivity extends Activity {
/** Called when the activity is first created. */
private Button button;
自定義對(duì)話框布局文件custom_alertdialog.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="15dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:background="@drawable/dialog_bg">
<!-- enter button -->
<ImageButton
android:id="@+id/enter_btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
?
?
文章鏈接: http://www.qzkangyuan.com/24351.html
文章標(biāo)題:AlertDialog自定義控件
文章版權(quán):夢(mèng)飛科技所發(fā)布的內(nèi)容,部分為原創(chuàng)文章,轉(zhuǎn)載請(qǐng)注明來(lái)源,網(wǎng)絡(luò)轉(zhuǎn)載文章如有侵權(quán)請(qǐng)聯(lián)系我們!
聲明:本站所有文章,如無(wú)特殊說(shuō)明或標(biāo)注,均為本站原創(chuàng)發(fā)布。任何個(gè)人或組織,在未征得本站同意時(shí),禁止復(fù)制、盜用、采集、發(fā)布本站內(nèi)容到任何網(wǎng)站、書(shū)籍等各類(lèi)媒體平臺(tái)。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。